package cn.hzu580.bean;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import cn.hzu580.dao.BaseDAO;
import cn.hzu580.entity.Mission;
import cn.hzu580.entity.Notice;
import cn.hzu580.entity.User;
import cn.hzu580.util.DateUtil;

@Component
public class NoticeSender {
	
	@Resource(name="DAO")
	private BaseDAO baseDAO;

	
	public void send(String content, User object) {
		Notice notice = new Notice();
		notice.setContent(content);
		notice.setOwner(object);
		notice.setTime(DateUtil.now());
		baseDAO.insert(notice);
	}
	
	public void send(String content, User object, Mission mission) {
		Notice notice = new Notice();
		notice.setContent(content);
		notice.setOwner(object);
		notice.setTime(DateUtil.now());
		notice.setMission(mission);
		baseDAO.insert(notice);
	}
	
	public void send(String content, User object, String url) {
		Notice notice = new Notice();
		notice.setContent(content);
		notice.setOwner(object);
		notice.setTime(DateUtil.now());
		notice.setUrl(url);
		baseDAO.insert(notice);
	}

	public BaseDAO getBaseDAO() {
		return baseDAO;
	}

	public void setBaseDAO(BaseDAO baseDAO) {
		this.baseDAO = baseDAO;
	}
	
	
	
}
